package com.packer.ext.base;

import android.app.Application;
import android.content.Context;

import com.ladingwu.glidelibrary.GlideImageLocader;
import com.lasingwu.baselibrary.ImageLoaderConfig;
import com.lasingwu.baselibrary.ImageLoaderManager;
import com.lasingwu.baselibrary.LoaderEnum;
import com.packer.ext.http.RetrofitManager;
import com.packer.ext.util.LogUtils;
import com.packer.ext.util.Utils;
import com.tencent.bugly.crashreport.CrashReport;

import me.jessyan.retrofiturlmanager.RetrofitUrlManager;

/**
 * Created by hpb on 2018/4/11.
 */

public abstract class BaseApp extends Application {
  @Override public void onCreate() {
    super.onCreate();
    Utils.init(this);
    LogUtils.getConfig()
            .setLogSwitch(AppConstant.DEBUG)
            .setConsoleSwitch(AppConstant.DEBUG)
            .setGlobalTag(null)
            .setLogHeadSwitch(true)
            .setLog2FileSwitch(false)
            .setBorderSwitch(true)
            .setStackDeep(1);
    ImageLoaderConfig config = new ImageLoaderConfig.Builder(LoaderEnum.GLIDE,new GlideImageLocader())
            .maxMemory(40*1024*1024L)
            .build();
    ImageLoaderManager.getInstance().init(this,config);
    CrashReport.initCrashReport(this);
    RetrofitManager.getInstance()
//            .setSslSocketFactory()
//            .setCache()
//            .setHeaders()
            .init(getAppDomain());
    RetrofitUrlManager.getInstance().setDebug(AppConstant.DEBUG);
  }


  /**
   * 添加多域名
   * @param name
   * @param url
   */
  protected void addDomain(String name,String url){
    RetrofitUrlManager.getInstance().putDomain(name,url);
  }

  public  abstract String getAppDomain();

}
